import {
  getOrderStatusList
} from "@/api/order/mesProdOrderPlan"
import {
  getLineCodeList //查询线体
} from "@/api/employee/mesUserExtend"

import url from "@/axios/url"
const { mesUrl } = url()
let vm = null
const sendThis = (_this) => {
  vm = _this
}
export { sendThis }
// 列表头按钮配置
export const operateList = [
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", // 点击时返回的标识
  },
]
// 搜索条件配置
export const searchConfig = {
  data () {
    const self = this
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          planCode: {
            type: "input",
            label: $i18n.t("suitAnalyse.planCode")
          },
          prodCode: {
            type: "input",
            label: $i18n.t("suitAnalyse.prodCode")
          },
          prodName: {
            type: "input",
            label: $i18n.t("suitAnalyse.prodName")
          },
          planBeginDate: {
            type: "daterange",
            label: $i18n.t("suitAnalyse.planBeginDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planBeginDateMin", "planBeginDateMax"]
            }
          },
          planEndDate: {
            type: "daterange",
            label: $i18n.t("suitAnalyse.planEndDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planEndDateMin", "planEndDateMax"]
            }
          },
          workshopCode: {
            label: $i18n.t("common.workshopName"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 4,
                modelingType: "0"
              }
              const list = await getLineCodeList(params)
              return list.data.result
            }
          },
          lineCode: {
            label: $i18n.t("common.line"),
            type: "select",
            optionsLinkageFields: ["workshopCode"],
            isReloadOptions: true,
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              if (data.workshopCode) {
                const list = await getLineCodeList({
                  modelingCode: data.workshopCode,
                });
                return list.data.result;
              } else {
                return [];
              }
            }
          },
          orderStatus: {
            label: $i18n.t("suitAnalyse.orderStatus2"),
            type: "select",
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getOrderStatusList()
              return list.data.result
            }
          }
        }
      }
    }
  }
}
